package com.zr.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.ShowScopeDao;
import com.zr.model.Cdisstation;

@Repository("shscdai")
public class ShowScopeDaoImpl<T> extends BaseDaoImpl<T> implements ShowScopeDao<T> {

	@Override
	public List<Cdisstation> getDisstation(int page, int rows) {
		String hql="from Cdisstation";
		//select cd.disid,cd.disname,cd.distypeid,cd.disscope,cd.disprice,cd.instation 
		//cd.cuser.uname,
		Query query=this.getCurrentSession().createQuery(hql);
		//Query query=this.getSessionFactory().openSession().createQuery(hql);
		
		query.setFirstResult((page-1)*rows);
		query.setMaxResults(rows);
		List<Cdisstation>li=query.list();
		
		return li;
	}

	@Override
	public Integer findStation() {
		
		String hql="select count(cd.disid) from Cdisstation as cd";
		
		Query query=this.getSessionFactory().openSession().createQuery(hql);
		
		int count = ((Number)query.uniqueResult()).intValue();
		//Object t=query.uniqueResult();
		
		return count;
	}
	
	
	

}
